package aiguigu08.constructor.exer3;

/**
 * ClassName: Account
 * Package: aiguigu08.constructor.exer3
 * Description:
 *
 * @Author ZY
 * @Create 2024/10/11 22:05
 * @Version 1.0
 */
public class Account {
    private int id;//账号
    private double balance;//余额
    private double annuallnterestRate;//年利率

    public Account(int i, double b, double a) {
        id = i;
        balance = b;
        annuallnterestRate = a;
    }

    public void setId(int i) {
        id = i;
    }

    public int getId() {
        return id;
    }

    public void setBalance(double b) {
        balance = b;
    }

    public double getBalance() {
        return balance;
    }

    public void setAnnuallnterestRate(double a) {
        annuallnterestRate = a;
    }

    public double getAnnuallnterestRate() {
        return annuallnterestRate;
    }

    //取钱
    public void withdraw(double amount) {
        if (amount <= balance){
            balance -= amount;
            System.out.println("成功取出: " + amount);
        }else{
            System.out.println("余额不足，取款失败");
        }
    }

    //存钱
    public void deposit(double amount){
        if (amount > 0){
            balance += amount;
            System.out.println("成功存入: " + amount);
        }
    }
}
